package com.hmall.api.client;

import com.hmall.api.client.fallback.ItemClientFallback;
import com.hmall.api.dto.ItemDTO;
import com.hmall.api.dto.OrderDetailDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

//当前类是Feign接口,主要作用是用来远程调用商品微服务
@FeignClient(value = "item-service",fallbackFactory = ItemClientFallback.class)
public interface ItemClient {

    /**
     * 根据商品ids查询商品信息
     * @param ids
     * @return
     */
    @GetMapping("/items")
    List<ItemDTO> queryItemByIds(@RequestParam("ids") List<Long> ids);


    @PutMapping("/items/stock/deduct")
    void deductStock(@RequestBody List<OrderDetailDTO> items);


    @PutMapping("/items/stock/add")
    void addStock(@RequestBody List<OrderDetailDTO> items);
}
